package cn.liontalk.springboot_es.entity;


import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Data
@Document(indexName = "blog",type="doc",
        /**
         * useServerConfiguration 使用线上的配置
         * createIndex 不要在启动的时候创建index
        */
        useServerConfiguration = true,createIndex = false)
public class EsLogSearchBlog {


    @Id
    private Integer id;

    @Field(type= FieldType.Text,analyzer = "ik_max_word")
    private String author;
    /**
     * 设置内容的字段类型
     */
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String content;

    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String title;

    /**
     * 用户自定义的时间格式
     */
    @Field(type = FieldType.Date,format = DateFormat.custom,
            pattern ="yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || epoch_millis")
    private Date createTime;

    @Field(type = FieldType.Date,format = DateFormat.custom,
            pattern ="yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || epoch_millis")
    private Date updateTime;


}
